
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  // history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      redirect: "/profile",
    },
    {
      path: "/profile",
      component: () => import("@/views/user/ProfileEdit.vue"),
      meta: { title: "个人资料" },
    },
    {
      path: "/address",
      component: () => import("@/views/address/AddressManager.vue"),
      meta: { title: "地址列表" },
    },
    {
      path: "/address/:id",
      component: () => import("@/views/address/AddressEdit.vue"),
      meta: { title: "地址管理" },
    },
  ],
});
// router.beforeEach((to, from, next) => {
//   if (true) {
//     next()
//   } else {
//     next("/login")
//   }
  
// })
router.afterEach((to, from) => {
  document.title=to.meta.title as string
})

export default router
